home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr48 / 386p_200.zip / 386ARG.INC < prev    next >
Text File  |  1994-12-02  |  3KB  |  75 lines

  1. ; 386POWER COMMAND LINE SCANNER:
  2. ; EXECUTE _ArgInit BEFORE ANY FILE I/O
  3. ; OR THE DEFAULT DTA (the place where the command line arguments are)
  4. ; MAY BE TRASHED
  5.  
  6. ; 386arg follows this simple parameter convention:
  7. ; Arguments are string made of non-blank (i.e space o tab) characters.
  8. ; Strings with a "-" as the first character are command line switches.
  9. ; Strings without "-" are file names.
  10.  
  11. ; so: 
  12. ;      -DEBUG  -F -f -FOOBAR -SELFDESCTRUCT  -SD  
  13. ; are options.
  14. ; while:   
  15. ;      foobar.dat    d:\LonG\PaTh\Name.dat $%^&$$#  !wow!
  16. ;      rock'n'roll  *)(&#  +cool 
  17. ; are different file names.
  18. ; I found that this simple syntax fits most of my needs.
  19.  
  20. extrn _ArgInit:near
  21.         ; reads the command line parameters from DTA,
  22.         ; copies them into a buffer and convert it to a list
  23.         ; of ASCIIZ (c strings) terminated by a null string
  24.         ; No parsing is made on strings
  25.         ; ALL blank character are skipped
  26.  
  27. extrn _ArgFile:near
  28.         ; reads from the command line the next "file name"
  29.         ; (any non-blank string NOT STARTING with "-" )
  30.         ; and returns it into ESI, if all file names have been read
  31.         ; or if no file name are present it returns a NULL ASCIIZ
  32.         ; ( a pointer to character 0).
  33.  
  34. extrn _ArgOpt:near
  35.         ; reads from the command line the next "option"
  36.         ; (any non-blank string STARTING with "-" )
  37.         ; and returns a pointer to it into ESI, if all options have been read
  38.         ; or if no options are present it returns a NULL ASCIIZ
  39.         ; ( a pointer to character 0).
  40.         ; N.B. the "-" header of the option string is automatically
  41.         ;      discarded (but other "-" inside it are not stripped away)
  42.  
  43.  
  44. ; if you PROGRAM.EXE makes use of 386arg
  45. ; and you execute it with the following command line:
  46. ; PROGRAM -FOOBAR foo.dat -D gnat warp.001 
  47. ; the comman line args are "-FOOBAR foo.dat -D -FROG gnat warp.001"
  48. ; The first call to _ArgFile returns into eax a pointer to "foo.dat"
  49. ; The 2nd returns "gnat"
  50. ; The 3rd returns "warp.001"
  51. ; The 4th returns and empty string
  52. ; (a pointer to ascii char 0, the string terminator)
  53.  
  54. ; If you call _ArgOpt you get:
  55. ; "FOOBAR" first, "D" second, "FROG" third and empty string fourth
  56.  
  57. ; N.B.  "xxxx" is equivalent to   db 'xxxx',0  (it's a C string)
  58.  
  59. ; Handling 'options' and 'pure filenames' in different list
  60. ; lets you place options where you want without predefined order.
  61.  
  62. ; If you type: PROGRAM ^&**((%$
  63. ; The first call to _ArgFile returns "^&**((%$"
  64. ; So check it before trying to open files with the result of _ArgFile
  65.  
  66. ; N.B if you write "--" on command lined, it will be read as 'option' "-"
  67. ;     (only the head "-" is discarded)
  68. ;
  69. ; If you want option+filename, simply write 'em joined together
  70. ; i.e:
  71. ;     -Spippo.txt or -S=pippo.txt  for  "SAVE into pippo.txt"
  72. ;
  73. ; By the way, this simplifies the rest of the command line decoding.
  74.  
  75.